package com.suray.wcs.service.newled;

import com.suray.basic.wcs.utils.LoggerUtil;
import com.suray.commin.core.utils.SpringContextHolder;
import com.suray.wcs.service.system.entity.DeviceDB;
import com.suray.wcs.service.system.service.impl.DeviceDBServiceImpl;

import java.io.IOException;

public class LedShowData extends Thread {
    private static DeviceDBServiceImpl ledService = SpringContextHolder.getBean(DeviceDBServiceImpl.class);


    /**
     * 发送显示内容到led
     *
     * @param ledNo    : led编号
     * @param district : 需要显示内容所在的区域
     * @param message  : 需要显示的内容
     * @throws IOException
     */
    public static void ledSend(int ledNo, String district, String message) throws IOException {
        LoggerUtil.info("led屏发送数据, ledNo:" + ledNo + ", district:" + district + ", message:" + message, LedShowData.class);
        DeviceDB ledDBByLedNo = ledService.getById(ledNo);
        LedBean ledBean = new LedBean(ledDBByLedNo.getIp(), ledDBByLedNo.getPort(), ledDBByLedNo.getData());
        ledBean.sendMessage(message, district, null);
    }
}
